package com.jnu.hospitalexamination.mapper;

import com.jnu.hospitalexamination.entity.Checkitem;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.jnu.hospitalexamination.entity.Checkitemdetailed;
import com.jnu.hospitalexamination.entity.vo.CheckitemVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
* @author Nowonder
* @description 针对表【checkitem】的数据库操作Mapper
* @createDate 2024-07-21 20:11:05
* @Entity .entity.Checkitem
*/
@Mapper
public interface CheckitemMapper extends BaseMapper<Checkitem> {
    /**
     * 根据订单id获取检查项目（detail）
     * @param orderId
     * @return
     */
    @Select("SELECT cid.* FROM orders o\n" +
            "JOIN setmealdetailed sd ON o.smId=sd.smId\n" +
            "JOIN checkitemdetailed cid ON sd.ciId=cid.ciId\n" +
            "WHERE o.orderId=#{orderId}")
    List<Checkitemdetailed> getCheckitemdetailedByOrderId(Integer orderId);
    /**
     * 根据套餐smid获取检查项目（大项）
     * @param smid
     * @return
     */
    @Select("select s.name,s.type,c.ciId,c.ciName,c.ciContent,c.meaning,s.price from checkitem c\n" +
            "join setmealdetailed sd on c.ciId = sd.ciId\n" +
            "join setmeal s on s.smId = sd.smId\n" +
            "where s.smId=#{smid}")
    List<CheckitemVO> selectCheckitemBySmid(Integer smid);

}




